Specifies the command(s) to perform if an IF-statement evaluates to FALSE. When more than one command is present, enclose them in a block (braces).
Else
Every use of ELSE must belong to (be associated with) an IF-statement above it. An ELSE always belongs to the nearest unclaimed IF-statement above it unless a block is used to change that behavior. An ELSE can be followed immediately by any other single command on the same line. This is most often used for "else if" ladders (see examples).
When an IF or an ELSE owns more than one line, those lines must be enclosed in braces. However, if only one line belongs to an IF or ELSE, the braces are optional. For example:
if count > 0 MsgBox Press OK to begin the process. else { WinClose Untitled - Notepad MsgBox There are no items present. }
In v1.0.41+, the One True Brace (OTB) style may optionally be used around an "else". For example:
if IsDone { ... } else if (x < y) { ... } else { ... }
See Blocks. Also, every IF-command can use ELSE, including IfWinActive, IfWinExist, IfMsgBox, IfInString, IfBetween, IfIn, IF, and IF (expression).
IfWinExist, Untitled - Notepad { WinActivate Send This is a test.{Enter} } else { WinActivate, Some Other Window MouseClick, left, 100, 200 } if x = 1 Gosub, a1 else if x = 2 ; "else if" style Gosub, a2 else IfEqual, x, 3 ; alternate style { Gosub, a3 Sleep, 1 } else Gosub, a4 ; i.e. Any single command can be on the same line with an ELSE. ; Also OK: IfEqual, y, 1, Gosub, b1 else { Sleep, 1 Gosub, b2 }